package com.jeesite.modules.storage.common;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;

/**
 * 服务端响应类
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
public class ServerResponse<T> implements Serializable {

    public Integer code;
    public String msg;
    public T data;

    private ServerResponse(Integer code,String msg,T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> ServerResponse<T> createBySuccess(Integer code,String msg) {
        return new ServerResponse<T>(code,msg,null);
    }

    public static <T> ServerResponse<T> createBySuccess(Integer code,T data) {
        return new ServerResponse<T>(code,null,data);
    }

    public static <T> ServerResponse<T> createBySuccess(Integer code,String msg,T data) {
        return new ServerResponse<T>(code,msg,data);
    }
}
